package com.demo.system.auth.service.impl;


import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.demo.common.entity.User;
import com.demo.common.response.Result;
import com.demo.system.auth.service.AuthService;
import com.demo.system.service.UserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 认证服务实现类
 *
 * @author why
 * @since 2.4.0
 */
@Service
@RequiredArgsConstructor
@Slf4j
public class AuthServiceImpl implements AuthService {

    private final UserService userService;

    @Override
    public Result<?> login(String username, String password) {
        User one = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getPhone, username).eq(User::getPassword, password));
        if (ObjectUtil.isNull(one)) {
            return Result.error("用户名账号或密码错误");
        }
        return Result.success(one);
    }

    @Override
    public void logout() {

    }
}
